using System;
using System.Collections.Generic;
using ScrumManagementTool.db.interfaces;

namespace ScrumManagementTool.db
{
    public class DbLogin : IDbLogin
    {
        private IDbGateway dbGateway;

        public DbLogin():this(new DbGateway())
        {
        }

        public DbLogin(IDbGateway dbGateway)
        {
            this.dbGateway = dbGateway;
        }

        public bool AttemptLogin(string username, string password)
        {
            string stmt = "SELECT id FROM members WHERE username=:username AND password=:password";

            IDictionary<string, string> values = new Dictionary<string, string>();
            values.Add(new KeyValuePair<string, string>(":username", username));
            values.Add(new KeyValuePair<string, string>(":password", password));

            return dbGateway.ExecuteSelectForBool(stmt, values);
        }
    }
}